 
 //jquery 本地图片在页面渲染查看插件
 
 
 
 /*
  
  * <body>
		
		 <div id="ImportHead">
        <table border="0" class="frm" style="height: 35px; width: auto; padding-left: 5px;
            padding-top: 1px;">
            <tr style="width: 300px; height: 400px;">
                <th>
                    选择图1：
                </th>
                <td>
                    <input type="file" id="file1">
                    <div id="image-wrap1" style="width: 300px; height: 300px; border: solid 1px lightGray">
                    </div>
                </td>
            </tr>
            <tr>
                <td colspan="2" style="text-align: right">
                    <input type="submit" id="btnUpload" class="btnSearch" value="上传" />
                </td>
            </tr>
        </table>
    </div>
		
		<script type="text/JavaScript">
//图片显示插件
       
        $(document).ready(function () {
            //图片显示插件
            $.imageFileVisible({ wrapSelector: "#image-wrap1",
                fileSelector: "#file1",
                width: 300,
                height: 300
           });
        });
  * 
  * */
 
 
 
 
 ;(function ($) {
            $.imageFileVisible = function (options) {
                // 默认选项
                var defaults = {
                    //包裹图片的元素
                    wrapSelector: null,
                    //<input type=file />元素
                    fileSelector: null,
                    width: '100%',
                    height: 'auto',
                    errorMessage: "不是图片",
                    isOneImg:true //是一张图片
                };
                // Extend our default options with those provided.    
                var opts = $.extend(defaults, options);
                $(opts.fileSelector).on("change", function () {
                    var file = this.files[0];
                    var imageType = /image.*/;
                    if (file.type.match(imageType)) {
                        var reader = new FileReader();
                        reader.onload = function () {
                            var img = new Image();
                            img.src = reader.result;
                            
                            $(img).width(opts.width);
                            $(img).height(opts.height);
                            //清空
                           // $(opts.wrapSelector).empty();
                           
                           //判断是否是上传一张  还是多张
                           if(opts.isOneImg==true){
                           	
                           	 $(opts.wrapSelector).empty();
                           }
                           
                            $(opts.wrapSelector).append(img);
                        };
                        reader.readAsDataURL(file);
                    } else {
                        alert(opts.errorMessage);
                    }
                });
            };
        })(jQuery);